Code
library(tidyverse)
library(ggtree)
library(ggtreeExtra)
library(ape)
library(ggnewscale)
library(RColorBrewer)
library(svglite)
source("scripts/metadata_colors.R")Libraries
library(tidyverse)
library(ggtree)
library(ggtreeExtra)
library(ape)
library(ggnewscale)
library(RColorBrewer)
library(svglite)
source("scripts/metadata_colors.R")Paths
metadata_path <-
"data/processed/metadata_ashton_desj_all_weavepop_final_H99.csv"
chrom_metrics_path <-
"results/tables/chromosome_cnv_categories.tsv"
merged_tree_path <-
"data/processed/tree_merged.newick"
tree_merged_duplications_path1 <-
"results/trees_dups/tree_duplications_full1.png"
tree_merged_duplications_path2 <-
"results/trees_dups/tree_duplications_full2.png"
tree_merged_duplications_path3 <-
"results/trees_dups/tree_duplications_full3.png"
tree_merged_duplications_path4 <-
"results/trees_dups/tree_duplications_full4.png"
tree_merged_duplications_path5 <-
"results/trees_dups/tree_duplications_full5.png"
tree_merged_duplications_path6 <-
"results/trees_dups/tree_duplications_full6.png"
tree_merged_duplications_path7 <-
"results/trees_dups/tree_duplications_full7.png"
tree_merged_duplications_path8 <-
"results/trees_dups/tree_duplications_full8.png"
tree_merged_duplications_small1 <-
"results/trees_dups/tree_duplications_small1.png"
tree_merged_duplications_small2 <-
"results/trees_dups/tree_duplications_small2.png"
tree_merged_duplications_small3 <-
"results/trees_dups/tree_duplications_small3.png"
tree_merged_duplications_small4 <-
"results/trees_dups/tree_duplications_small4.png"
tree_merged_duplications_small5 <-
"results/trees_dups/tree_duplications_small5.png"
tree_merged_duplications_small6 <-
"results/trees_dups/tree_duplications_small6.png"
tree_merged_duplications_small7 <-
"results/trees_dups/tree_duplications_small7.png"
tree_merged_duplications_small8 <-
"results/trees_dups/tree_duplications_small8.png"
tree_merged_duplications_small9 <-
"results/trees_dups/tree_duplications_small9.png"
tree_merged_duplications_small10 <-
"results/trees_dups/tree_duplications_small10.png"Load the necessary data
metadata <- read.csv(
metadata_path,
header = TRUE)%>%
select(strain, everything())Get one dataframe for each variable to be plotted as a separate metadata column in the tree
metadata$vni_subdivision <- factor(metadata$vni_subdivision,
levels = c("VNIa-4", "VNIa-5", "VNIa-32",
"VNIa-93", "VNIa-X", "VNIa-Y", "VNIb",
"VNIc", "VNIa-outlier"))
metadata$country_of_origin <- factor(metadata$country_of_origin,
levels = names(country_colors))
metadata$continent <- factor(metadata$continent,
levels = names(continent_colors))
sublineage <- metadata %>%
filter(lineage == "VNI")%>%
select(strain, vni_subdivision)%>%
column_to_rownames("strain")%>%
droplevels()
lineage <- metadata %>%
select(strain, lineage)%>%
column_to_rownames("strain")
dataset <- metadata %>%
select(strain, dataset)%>%
column_to_rownames("strain")
source <- metadata %>%
select(strain, source)%>%
column_to_rownames("strain")
country <- metadata %>%
select(strain, country_of_origin)%>%
column_to_rownames("strain")
continent <- metadata %>%
select(strain, continent)%>%
column_to_rownames("strain") chrom_metrics <- read.delim(
chrom_metrics_path,
header = TRUE,
sep = "\t"
)
chrom_metrics$chrom_category_aneuploidy <- factor(chrom_metrics$chrom_category_aneuploidy,
levels = c("Full", "Partial", "Euploid"))
chrom_metrics$chrom_category_size <- factor(chrom_metrics$chrom_category_size,
levels = c("Large", "Medium", "Small", "Absent"))Make matrix of coverage percent per chromosome for duplications and deletions
dup_coverage <- chrom_metrics %>%
filter(cnv == "duplication")%>%
select(strain, chromosome, coverage_percent)%>%
pivot_wider(names_from = chromosome, values_from = coverage_percent)%>%
column_to_rownames("strain") Make matrix of aneuploidy category per chromosome for duplications
dup_category_aneuploidy <- chrom_metrics %>%
filter(cnv == "duplication")%>%
select(strain, chromosome, chrom_category_aneuploidy)%>%
pivot_wider(names_from = chromosome, values_from = chrom_category_aneuploidy)%>%
column_to_rownames("strain") Make matrix of size category per chromosome for duplications
dup_category_size <- chrom_metrics %>%
filter(cnv == "duplication")%>%
select(strain, chromosome, chrom_category_size)%>%
pivot_wider(names_from = chromosome, values_from = chrom_category_size)%>%
column_to_rownames("strain") dup_chroms <- chrom_metrics %>%
filter(cnv == "duplication")%>%
select(strain, chromosome, chrom_category_aneuploidy)%>%
mutate(chrom_category_aneuploidy = as.character(chrom_category_aneuploidy))%>%
mutate(chromosome_2 = ifelse(chrom_category_aneuploidy == "Partial", "Euploid",
ifelse(chrom_category_aneuploidy == "Full", chromosome, "Euploid")))%>%
group_by(chromosome)%>%
filter(!all(chromosome_2 == "Euploid"))%>%
ungroup()%>%
select(strain, chromosome, chromosome_2)%>%
pivot_wider(names_from = chromosome,
values_from = chromosome_2)%>%
column_to_rownames("strain")tree <- read.tree(merged_tree_path)Remove tips that are not in metadata$strain
tree <- drop.tip(tree, setdiff(tree$tip.label, metadata$strain))Get the node number of the Most Recent Common Ancestor of each lineage
VNI_node <- getMRCA(tree, c("Tu241-1","UI_31647-2"))
VNII_node <- getMRCA(tree, c("C2","C12"))
VNBI_node <- getMRCA(tree, c("Tu229-1","Ftc267-2"))
VNBII_node <- getMRCA(tree, c("MW-RSA3321","MW-RSA3179"))
VNIa4_node <- getMRCA(tree, c("04CN-30-008","UI_31647-2"))
VNIa5_node <- getMRCA(tree, c("BMD852","14936_1#45"))
VNIa93_node <- getMRCA(tree, c("04CN-65-080","04CN-65-002"))
VNIa32_node <- getMRCA(tree, c("BMD942","BMD2801"))
VNIaX_node <- getMRCA(tree, c("Bt48","04CN-63-007"))
VNIaY_node <- getMRCA(tree, c("04CN-65-073","Bt138"))
VNIa_node <- getMRCA(tree, c("04CN-30-008","BMD852"))
VNIb_node <- getMRCA(tree, c("04CN-65-096","MW-RSA722"))
VNIc_node <- getMRCA(tree, c("Bt20","Bt11"))nodes_lineages <- data.frame(
lineage = c("VNI", "VNII", "VNBI", "VNBII"),
mrca = c(VNI_node, VNII_node, VNBI_node, VNBII_node))
nodes_sublineages <- data.frame(
sublineage = c("VNII", "VNBII", "VNBI", "VNIb","VNIc", "VNIa"),
mrca = c(VNII_node, VNBII_node, VNBI_node, VNIb_node, VNIc_node, VNIa_node),
shading = c("gray30", "gray60","gray30", "gray60","gray30", "gray60"))
nodes_vnisublineages <- data.frame(
sublineage = c("VNIb","VNIc", "VNIa"),
mrca = c(VNIb_node, VNIc_node, VNIa_node),
shading = c("gray90", "gray70","gray90"))
nodes_vniasublineages <- data.frame(
sublineage = c("VNIb", "VNIc", "VNIa-4", "VNIa-32", "VNIa-93", "VNIa-5"),
mrca = c(VNIb_node, VNIc_node, VNIa4_node, VNIa32_node, VNIa93_node, VNIa5_node),
shading = c("gray70", "gray90","gray70", "gray90","gray70", "gray90"))sublineage_shading <- nodes_sublineages$shading
names(sublineage_shading) <- nodes_sublineages$sublineage
vnisublineage_shading <- nodes_vnisublineages$shading
names(vnisublineage_shading) <- nodes_vnisublineages$sublineage
vniasublineage_shading <- nodes_vniasublineages$shading
names(vniasublineage_shading) <- nodes_vniasublineages$sublineageColor palettes
chrom_colors <- brewer.pal(7, "Dark2")
names(chrom_colors) <- c("chr01", "chr04",
"chr06", "chr09",
"chr12","chr13", "chr14")
chrom_dup_colors <- c(chrom_colors, "Euploid" = "grey93")
countries_final <- levels(droplevels(country[rownames(country) %in% tree$tip.label, ]))category_size_colors <-c("#8E0152","#2171B5", "#DEEBF7","#F7FBFF" )
names(category_size_colors) <- levels(chrom_metrics$chrom_category_size)
category_aneuploidy_colors <-c("#8E0152","#2171B5", "#DEEBF7" )
names(category_aneuploidy_colors) <- levels(chrom_metrics$chrom_category_aneuploidy)m <- ggtree(tree,
ladderize = TRUE,
layout = "circular",
branch.length = "none",
size = 0.1) %<+% metadata +
geom_hilight(data=nodes_sublineages,
aes(node=mrca, fill=sublineage), alpha = 0.3)+
scale_fill_manual(name = "Sublineage", values = sublineage_shading)+
guides(fill = FALSE)+
new_scale_fill()+
geom_tree(size = 0.1)
m1 <- gheatmap(m, continent, width=.05, colnames=FALSE) +
scale_fill_manual(values = continent_colors, name="Continent",
na.translate = FALSE, limits = names(continent_colors))+
guides(fill = guide_legend(order = 1, ncol = 2))+
new_scale_fill()
m2 <- gheatmap(m1, source, width=.05, colnames=FALSE, offset=2.3) +
scale_fill_manual(values = source_colors, name="Source", na.translate = FALSE)+
guides(fill = guide_legend(order = 2))+
new_scale_fill()
m3 <- gheatmap(m2, dup_chroms, width=.32, colnames = FALSE, offset=4.7) +
scale_fill_manual(values = chrom_dup_colors,
name="Duplicated\nchromosomes",
na.translate = FALSE )+
guides(fill = guide_legend(order = 3, ncol = 2))+
geom_cladelab(data = nodes_sublineages,
mapping = aes(node = mrca, label = sublineage, color = sublineage),
align = TRUE, face = "bold",
fontsize = 3,
angle = "auto", offset = 18)+
scale_color_manual(name = "Sublineage", values = sublineage_shading)+
guides(color = FALSE)+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3a <- ggtree(tree,
ladderize = TRUE,
layout = "circular",
branch.length = "none",
size = 0.1) %<+% metadata +
geom_tiplab(color = "black", size = 0.3, offset = 0.01)+
geom_hilight(data=nodes_vnisublineages,
aes(node=mrca, fill=sublineage), alpha = 0.8)+
scale_fill_manual(name = "Sublineage", values = vnisublineage_shading)+
guides(fill = FALSE)+
new_scale_fill()+
geom_tree(size = 0.1)+
geom_text(aes(label = nodes_lineages$lineage[match(node, nodes_lineages$mrca)]),
size = 2, , fontface = "bold",
hjust = 1.25, vjust = -0.5)+
geom_tippoint(aes(color = country_of_origin), shape = 18,
size = 0.01)+
scale_color_manual(name = "Country", values = country_colors,
limits = countries_final)+
guides(color = guide_legend(override.aes = list(size = 5), order = 1, ncol = 2))
a1 <- gheatmap(a, source, width=.05, colnames=FALSE, offset=3.7) +
scale_fill_manual(values = source_colors, name="Source", na.translate = FALSE)+
guides(fill = guide_legend(order = 2))+
new_scale_fill()
a2 <- gheatmap(a1, dup_chroms, width=.32, colnames = FALSE, offset=6) +
scale_fill_manual(values = chrom_dup_colors,
name="Duplicated\nchromosomes",
na.translate = FALSE )+
guides(fill = guide_legend(order = 5))+
geom_cladelab(data = nodes_vnisublineages,
mapping = aes(node = mrca, label = sublineage),
align = TRUE, face = "bold",
fontsize = 3,
angle = "auto", offset = 20)+
theme(legend.position = "bottom",
legend.direction = "vertical")
a2m <- ggtree(tree,
ladderize = TRUE,
layout = "circular",
branch.length = "none",
size = 0.1) %<+% metadata +
geom_tree(size = 0.1)+
geom_text(aes(label = nodes_sublineages$sublineage[match(node, nodes_sublineages$mrca)]),
size = 2, , fontface = "bold",
hjust = 1.25, vjust = -0.5)
m1 <- gheatmap(m, continent, width=.05, colnames=FALSE) +
scale_fill_manual(values = continent_colors, name="Continent",
na.translate = FALSE, limits = names(continent_colors))+
guides(fill = guide_legend(order = 1, ncol = 2))+
new_scale_fill()
m2 <- gheatmap(m1, source, width=.05, colnames=FALSE, offset=2.3) +
scale_fill_manual(values = source_colors, name="Source", na.translate = FALSE)+
guides(fill = guide_legend(order = 2))+
new_scale_fill()
m3 <- gheatmap(m2, dup_chroms, width=.32, colnames = FALSE, offset=4.7) +
scale_fill_manual(values = chrom_dup_colors,
name="Duplicated\nchromosomes",
na.translate = FALSE )+
guides(fill = guide_legend(order = 3, ncol = 2))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path1, m3, height = 8, width = 6.5, units = "in", dpi = 1000)m3 <- gheatmap(m2, dup_coverage, width=.8, colnames = FALSE, offset=4.7) +
scale_fill_viridis_c(name = "% Coverage\nDuplicated",
direction = -1, na.value = "white",
option = "mako", limits = c(0,100))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path2, m3, height = 8, width = 6.5, units = "in", dpi = 1000)m3 <- gheatmap(m2, dup_category_aneuploidy, colnames = FALSE, offset=4.7) +
scale_fill_manual(name = "Category",values = category_aneuploidy_colors,
na.value = "white", limits = levels(chrom_metrics$chrom_category_aneuploidy))+
guides(fill = guide_legend(order = 3))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path3, m3, height = 8, width = 6.5, units = "in", dpi = 1000)m3 <- gheatmap(m2, dup_category_size, width=.8, colnames = FALSE, offset=4.7) +
scale_fill_manual(name = "Category",values = category_size_colors,
na.value = "white", limits = levels(chrom_metrics$chrom_category_size))+
guides(fill = guide_legend(order = 3))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path4, m3, height = 8, width = 6.5, units = "in", dpi = 1000)m <- ggtree(tree,
ladderize = TRUE,
layout = "circular",
branch.length = "none",
size = 0.1) %<+% metadata +
geom_tree(size = 0.1)+
geom_text(aes(label = nodes_sublineages$sublineage[match(node, nodes_sublineages$mrca)]),
size = 2, , fontface = "bold",
hjust = 1.25, vjust = -0.5)+
geom_tiplab(color = "black", size = 0.3, offset = 0.01)
m1 <- gheatmap(m, continent, width=.05, colnames=FALSE,offset=3.7 ) +
scale_fill_manual(values = continent_colors, name="Continent",
na.translate = FALSE, limits = names(continent_colors))+
guides(fill = guide_legend(order = 1, ncol = 2))+
new_scale_fill()
m2 <- gheatmap(m1, source, width=.05, colnames=FALSE, offset=6) +
scale_fill_manual(values = source_colors, name="Source", na.translate = FALSE)+
guides(fill = guide_legend(order = 2))+
new_scale_fill()
m3 <- gheatmap(m2, dup_chroms, width=.32, colnames = FALSE, offset=8) +
scale_fill_manual(values = chrom_dup_colors,
name="Duplicated\nchromosomes",
na.translate = FALSE )+
guides(fill = guide_legend(order = 3, ncol = 2))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path5, m3, height = 8, width = 6.5, units = "in", dpi = 1000)m3 <- gheatmap(m2, dup_coverage, width=.8, colnames = FALSE, offset=8) +
scale_fill_viridis_c(name = "% Coverage\nDuplicated",
direction = -1, na.value = "white",
option = "mako", limits = c(0,100))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path6, m3, height = 8, width = 6.5, units = "in", dpi = 1000)m3 <- gheatmap(m2, dup_category_aneuploidy, colnames = FALSE, offset=8) +
scale_fill_manual(name = "Category",values = category_aneuploidy_colors,
na.value = "white", limits = levels(chrom_metrics$chrom_category_aneuploidy))+
guides(fill = guide_legend(order = 3))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path7, m3, height = 8, width = 6.5, units = "in", dpi = 1000)m3 <- gheatmap(m2, dup_category_size, width=.8, colnames = FALSE, offset=8) +
scale_fill_manual(name = "Category",values = category_size_colors,
na.value = "white", limits = levels(chrom_metrics$chrom_category_size))+
guides(fill = guide_legend(order = 3))+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_path8, m3, height = 8, width = 6.5, units = "in", dpi = 1000)keep_strains <- chrom_metrics %>%
filter(cnv == "duplication", chrom_category_aneuploidy %in% c("Partial", "Full"))%>%
pull(strain)
keep_strains <- c(keep_strains, "H99", "Bt22", "Bt89")
tree_dups <- drop.tip(tree, setdiff(tree$tip.label, keep_strains))
sublineage <- sublineage %>%
filter(rownames(.) %in% keep_strains)%>%
droplevels()Get the node number of the Most Recent Common Ancestor of each lineage
VNI_node <- getMRCA(tree_dups, c("Bt139","H99"))
VNII_node <- getMRCA(tree_dups, c("8-1","C12"))
VNBI_node <- getMRCA(tree_dups, c("PMHc1001.ENR","NRHc5045.ENR.CLIN.ISO"))
VNBII_node <- getMRCA(tree_dups, c("Bt109","Bt34"))
VNIa4_node <- getMRCA(tree_dups, c("20427_3#26","20427_4#13"))
VNIa5_node <- getMRCA(tree_dups, c("Bt139","Bt141"))
VNIa93_node <- getMRCA(tree_dups, c("04CN-64-024","04CN-64-011"))
VNIa32_node <- getMRCA(tree_dups, c("04CN-65-072","In2632"))
VNIa_node <- getMRCA(tree_dups, c("20427_3#26", "Bt139"))
VNIb_node <- getMRCA(tree_dups, c("H99","MW-RSA6134"))
VNIc_node <- getMRCA(tree_dups, c("LP-RSA3042","PMHc1031A.ENR.INI.LP"))nodes_lineages <- data.frame(
lineage = c("VNI", "VNII", "VNBI", "VNBII"),
mrca = c(VNI_node, VNII_node, VNBI_node, VNBII_node))
nodes_sublineages <- data.frame(
sublineage = c("VNII", "VNBII", "VNBI", "VNIb","VNIc", "VNIa"),
mrca = c(VNII_node, VNBII_node, VNBI_node, VNIb_node, VNIc_node, VNIa_node),
shading = c("gray70", "gray90","gray70", "gray90","gray70", "gray90"))
nodes_vnisublineages <- data.frame(
sublineage = c("VNIb","VNIc", "VNIa"),
mrca = c(VNIb_node, VNIc_node, VNIa_node),
shading = c("gray90", "gray70","gray90"))
nodes_vniasublineages <- data.frame(
sublineage = c("VNIb", "VNIc", "VNIa-4", "VNIa-32", "VNIa-93", "VNIa-5"),
mrca = c(VNIb_node, VNIc_node, VNIa4_node, VNIa32_node, VNIa93_node, VNIa5_node),
shading = c("gray70", "gray90","gray70", "gray90","gray70", "gray90"))sublineage_shading <- nodes_sublineages$shading
names(sublineage_shading) <- nodes_sublineages$sublineage
vnisublineage_shading <- nodes_vnisublineages$shading
names(vnisublineage_shading) <- nodes_vnisublineages$sublineage
vniasublineage_shading <- nodes_vniasublineages$shading
names(vniasublineage_shading) <- nodes_vniasublineages$sublineagecountries_final <- levels(droplevels(country[rownames(country) %in% tree_dups$tip.label, ]))m <- ggtree(tree_dups,
ladderize = TRUE,
layout = "rectangular",
branch.length = "none",
size = 0.1) %<+% metadata +
geom_tiplab(color = "black", size = 1.5, offset = 0.1)+
geom_text(aes(label = nodes_lineages$lineage[match(node, nodes_lineages$mrca)]),
size = 2, , fontface = "bold",
hjust = 1.25, vjust = -0.5)+
geom_hilight(data=nodes_vnisublineages,
aes(node=mrca, fill=sublineage), alpha = 0.8)+
scale_fill_manual(name = "Sublineage", values = vnisublineage_shading)+
guides(fill = FALSE)+
new_scale_fill()+
geom_tree(size = 0.1)+
geom_tippoint(aes(color = dataset), shape = 18,
size = 1.5)+
scale_color_manual(name = "Dataset", values = dataset_colors)+
guides(color = guide_legend(override.aes = list(size = 5), order = 1))
m1 <- gheatmap(m, country, width=.03, colnames=FALSE, offset=2.3) +
scale_fill_manual(values = country_colors, name="Country",
na.translate = FALSE, limits = countries_final)+
guides(fill = guide_legend(order = 2, ncol = 2))+
new_scale_fill()m3 <- gheatmap(m1, dup_chroms, width=.25, colnames = TRUE,
colnames_position = "top",
colnames_angle = 45,
colnames_offset_y = 0.5,
font.size = 1.5, offset=2.8) +
ylim(0,70)+
scale_fill_manual(values = chrom_dup_colors,
name="Duplicated\nchromosomes",
na.translate = FALSE )+
guides(fill = guide_legend(order = 5))+
geom_cladelab(data = nodes_vnisublineages,
mapping = aes(node = mrca, label = sublineage),
align = TRUE, face = "bold",
fontsize = 3,
angle = 0, offset = 7)+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3m3 <- gheatmap(m1, dup_coverage, width=.25, colnames = TRUE,
colnames_position = "top",
colnames_angle = 45,
colnames_offset_y = 0.5,
font.size = 1.5, offset=2.8) +
ylim(0,70)+
scale_fill_viridis_c(name = "% Coverage\nDuplicated",
direction = -1, na.value = "white",
option = "mako", limits = c(0,100))+
guides(fill = guide_legend(order = 5))+
geom_cladelab(data = nodes_vnisublineages,
mapping = aes(node = mrca, label = sublineage),
align = TRUE, face = "bold",
fontsize = 3,
angle = 0, offset = 7)+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3m3 <- gheatmap(m1, dup_category_aneuploidy, width=.25, colnames = TRUE,
colnames_position = "top",
colnames_angle = 45,
colnames_offset_y = 0.5,
font.size = 1.5, offset=2.8) +
ylim(0,70)+
scale_fill_manual(name = "Category",values = category_aneuploidy_colors,
na.value = "white", limits = names(category_aneuploidy_colors))+
guides(fill = guide_legend(order = 5))+
geom_cladelab(data = nodes_vnisublineages,
mapping = aes(node = mrca, label = sublineage),
align = TRUE, face = "bold",
fontsize = 3,
angle = 0, offset = 7)+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3ggsave(tree_merged_duplications_small1, m3, height = 5, width = 6.5, units = "in", dpi = 900)m3 <- gheatmap(m1, dup_category_size, width=.25, colnames = TRUE,
colnames_position = "top",
colnames_angle = 45,
colnames_offset_y = 0.5,
font.size = 1.5, offset=2.8) +
ylim(0,70)+
scale_fill_manual(name = "Category",values = category_size_colors,
na.value = "white", limits = names(category_size_colors))+
guides(fill = guide_legend(order = 5))+
geom_cladelab(data = nodes_vnisublineages,
mapping = aes(node = mrca, label = sublineage),
align = TRUE, face = "bold",
fontsize = 3,
angle = 0, offset = 7)+
theme(legend.position = "bottom",
legend.direction = "vertical")
m3m <- ggtree(tree_dups,
ladderize = TRUE,
layout = "rectangular",
branch.length = "none",
size = 0.4) %<+% metadata +
geom_text(aes(label = nodes_sublineages$sublineage[match(node, nodes_sublineages$mrca)]),
size = 3, , fontface = "bold",
hjust = 1.25, vjust = -0.5)
m3 <- gheatmap(m, dup_chroms, width=.25,
colnames = TRUE, colnames_position = "top",
colnames_angle = 0,
colnames_offset_y = 2,
font.size = 2,
offset=0.1) +
scale_fill_manual(values = chrom_dup_colors,
name="Duplicated\nchromosomes",
na.translate = FALSE )+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3m3 <- gheatmap(m, dup_coverage, width=.7, colnames = TRUE,
colnames_position = "top",
colnames_angle = 0,
colnames_offset_y = 0.5,
font.size = 1.5, offset=0.1) +
scale_fill_viridis_c(name = "% Coverage\nDuplicated",
direction = -1, na.value = "white",
option = "mako", limits = c(0,100))+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3m3 <- gheatmap(m, dup_category_aneuploidy, width=1, colnames = TRUE,
colnames_position = "top",
colnames_angle = 90,
colnames_offset_y = 4,
font.size = 3, offset=0.1) +
ylim(0,70)+
labs(title = "b)")+
scale_fill_manual(name = "",values = category_aneuploidy_colors,
na.value = "white", limits = names(category_aneuploidy_colors))+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3ggsave(tree_merged_duplications_small1, m3, height = 4.5, width = 6.5, units = "in", dpi = 900)m3 <- gheatmap(m, dup_category_size, width=.7, colnames = TRUE,
colnames_position = "top",
colnames_angle = 0,
colnames_offset_y = 0.5,
font.size = 1.5, offset=0.1) +
scale_fill_manual(name = "Category",values = category_size_colors,
na.value = "white", limits = names(category_size_colors))+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3m <- ggtree(tree_dups,
ladderize = TRUE,
layout = "rectangular",
branch.length = "none",
size = 0.2) %<+% metadata +
geom_tiplab(color = "black", size = 1.5, offset = 0.01)+
geom_text(aes(label = nodes_sublineages$sublineage[match(node, nodes_sublineages$mrca)]),
size = 2, fontface = "bold",
hjust = 1.1, vjust = -0.5)
m3 <- gheatmap(m, dup_chroms, width=.25,
colnames = TRUE, colnames_position = "top",
colnames_angle = 0,
colnames_offset_y = 2,
font.size = 2,
offset=2) +
scale_fill_manual(values = chrom_dup_colors,
name="Duplicated\nchromosomes",
na.translate = FALSE )+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3m3 <- gheatmap(m, dup_coverage, width=.7, colnames = TRUE,
colnames_position = "top",
colnames_angle = 0,
colnames_offset_y = 0.5,
font.size = 1.5,
offset=2.5) +
# ylim(0,70)+
scale_fill_viridis_c(name = "% Coverage\nDuplicated",
direction = -1, na.value = "white",
option = "mako", limits = c(0,100))+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3m3 <- gheatmap(m, dup_category_aneuploidy, width=1, colnames = TRUE,
colnames_position = "top",
colnames_angle = 0,
colnames_offset_y = 0.5,
font.size = 1.5,
offset=2.5)+
scale_fill_manual(name = "",values = category_aneuploidy_colors,
na.value = "white", limits = names(category_aneuploidy_colors))+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3ggsave(tree_merged_duplications_small2, m3, height = 4.5, width = 6.5, units = "in", dpi = 900)m3 <- gheatmap(m, dup_category_aneuploidy, width=0.2, colnames = TRUE,
colnames_position = "top",
colnames_angle = 90,
colnames_offset_y = 1,
font.size = 1.5,
offset=2.5)+
ylim(0,66)+
scale_fill_manual(name = "",values = category_aneuploidy_colors,
na.value = "white", limits = names(category_aneuploidy_colors))+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3ggsave(tree_merged_duplications_small3, m3, height = 4.5, width = 6.5, units = "in", dpi = 900)m3 <- gheatmap(m, dup_category_size, width=.7, colnames = TRUE,
colnames_position = "top",
colnames_angle = 0,
colnames_offset_y = 0.5,
font.size = 1.5,
offset=2.5)+
scale_fill_manual(name = "Category",values = category_size_colors,
na.value = "white", limits = names(category_size_colors))+
theme(legend.position = "bottom",
legend.direction = "horizontal")
m3